package com.bdqn.t330.ch02.controller;

import com.bdqn.t330.ch02.repository.UserRepository;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

//组合注解@Controller  @ResponseBody
@RestController
public class HelloController {

    @Resource
    UserRepository userRepository;

    @RequestMapping("/hello")
    public Object hello() {
        System.out.println("hello");
        return "hello";
    }

    @RequestMapping("/user")
    public Object user(Long id) {
        System.out.println(id);
        return userRepository.getOne(id);
    }

}
